<template>
  <div>
    <div class="header_search" v-show="!showPhotoPage">
      <div v-if="!isAdvanceSearch">
        <div style="position: absolute; left: 10px; top: 10px;">
          <a-icon type="left-circle" theme="filled" style="font-size: 30px; color: #48D3A4; "
                  @click="backMain" />
        </div>
        <a-row type="flex" justify="center" style="padding-top: 10px;">
          <a-col span="12" :offset="4" >
            <!--                      <a-input-search v-model="searchContent"-->
            <!--                                      size="large"-->
            <!--                                      @search="onSearch">-->
            <!--                      </a-input-search>-->
            <a-input-search placeholder="" v-model="searchContent" @search="onSearch" allowClear>
              <a-select slot="addonBefore" :key="selectedType" :default-value="selectedType"
                        style="width: 120px; font-size: 18px; border-radius: 0 0 50px 50px; padding-left: 5px;"
                        @change="handleChange">
                <a-select-option :value="1">
                  姓名
                </a-select-option>
                <a-select-option :value="2">
                  单位
                </a-select-option>
                <a-select-option :value="3">
                  关键词
                </a-select-option>
              </a-select>
            </a-input-search>
          </a-col>
          <a-col span="2">
            <div style="line-height: 45px;">
                        <span
                          style="line-height: 20px; vertical-align: bottom; font-size: 16px; padding-left: 30px; cursor: pointer;"
                          @click="advancedSearch">
                            <span style="text-decoration: underline;">高级检索 ></span>&nbsp;
                        </span>
            </div>
          </a-col>
          <a-col span="2" :offset="2" v-if="talentInfoList.length > 0">
            <div style="line-height: 45px;">
                <span style="line-height: 20px; text-align: right; vertical-align: bottom; font-weight: bolder; color: red; font-size: 16px; padding-left:30px; cursor: pointer;"
                      @click="toFeedBack">
                      <span >结果反馈&nbsp;<a-icon type="edit" /></span>&nbsp;
                </span>
            </div>
          </a-col>
        </a-row>
        <br />
        <a-row type="flex" justify="center">
          <!--          <a-col span="6">-->
          <!--                    <a-card-->
          <!--                        style="margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);"-->
          <!--                        size="small">-->
          <!--                        <a slot="title" href="#" class="cardTit">-->
          <!--                            <a-icon type="calendar"/>&nbsp;&nbsp;&nbsp;日期</a>-->
          <!--                        &lt;!&ndash;                            <a slot="extra" href="#"><a-icon type="down" /></a>&ndash;&gt;-->
          <!--                        <a-range-picker style="width: 100%" @change="dataChange" format="YYYY-MM-DD"-->
          <!--                                        :value="rangeValue"/>-->
          <!--                        <a-row style="margin-top: 10px;">-->
          <!--                            <a-col span="8" style="text-align: left;">-->
          <!--                                <a-button type="primary" :ghost="selectedBtnType != 3" class="dateBtn"-->
          <!--                                          @click="setDateType(3)">近三年-->
          <!--                                </a-button>-->
          <!--                            </a-col>-->
          <!--                            <a-col span="8" style="text-align: center;">-->
          <!--                                <a-button type="primary" :ghost="selectedBtnType != 5" class="dateBtn"-->
          <!--                                          @click="setDateType(5)">近五年-->
          <!--                                </a-button>-->
          <!--                            </a-col>-->
          <!--                            <a-col span="8" style="text-align: right;">-->
          <!--                                <a-button type="primary" :ghost="selectedBtnType != 10" class="dateBtn"-->
          <!--                                          @click="setDateType(10)">近十年-->
          <!--                                </a-button>-->
          <!--                            </a-col>-->
          <!--                        </a-row>-->
          <!--                    </a-card>-->
          <!--                    <br/>-->
          <!--            <div class="chat">-->
          <!--              <a-card-->
          <!--                style="margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);"-->
          <!--                size="small">-->
          <!--                <a slot="title" href="#" class="cardTit">-->
          <!--                  <a-icon type="message" />&nbsp;&nbsp;&nbsp;专家信息AI检索</a>-->
          <!--                <iframe :src="basePath + 'talent_chat/index.html'"-->
          <!--                        style="height: 80vh; width: 100%; border: 0"></iframe>-->
          <!--              </a-card>-->
          <!--            </div>-->
          <!--                    <a-card-->
          <!--                        style="width: 80%; margin: auto; border-radius: 10px; background: linear-gradient(134.97deg, rgba(239,250,251,1) 0.1%,rgba(147,227,201,0.3) 98.05%);"-->
          <!--                        size="small">-->
          <!--                        <a slot="title" href="#" class="cardTit">-->
          <!--                            <a-icon type="bank"/>&nbsp;&nbsp;&nbsp;机构类型</a>-->
          <!--                        &lt;!&ndash;                            <a slot="extra" href="#"><a-icon type="down" /></a>&ndash;&gt;-->
          <!--                        <a-checkbox-group @change="onChangeDeptType" :value="searchObj.deptTypes">-->
          <!--                            <a-row v-for="item in deptTypes">-->
          <!--                                <a-col :span="24">-->
          <!--                                    <a-checkbox :value="item.name">-->
          <!--                                        <span style="font-size: 15px; line-height: 30px;">{{ item.name }}</span>-->
          <!--                                    </a-checkbox>-->
          <!--                                </a-col>-->
          <!--                            </a-row>-->
          <!--                        </a-checkbox-group>-->
          <!--                    </a-card>-->
          <!--          </a-col>-->
          <a-col span="22">
            <a-card style="border-radius: 10px;">
              <a-row :gutter="24">
                <a-col span="10">
                  <a-spin tip="数据加载中..." v-if="!isHaveDataTalent">
                    <div class="spin-content">
                    </div>
                  </a-spin>
                  <div v-if="isHaveDataTalent">
                    <div style="line-height: 30px; padding: 5px;">
                      <a-row>
                        <a-col span="12">
                          <div
                            style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 20px;">
                            高合作专家推荐
                          </div>
                        </a-col>
                        <a-col span="12" v-if="talentInfoList.length > 0">
                          <div style="font-weight: bolder; color: red; font-size: 14px; text-align: right; cursor: pointer;">
                            <a-radio-group v-model="sortIndex" @change="sortResult">
                              <a-radio-button :value="1">
                                合作次数排序<a-icon type="swap" :rotate="90"/>
                              </a-radio-button>
                              <a-radio-button :value="2">
                                贡献度排序<a-icon type="swap" :rotate="90"/>
                              </a-radio-button>
                            </a-radio-group>
                          </div>
                        </a-col>
                      </a-row>
                    </div>
                    <div v-if="talentInfoList.length > 0" style="padding-top: 15px;">
                      <div v-for="(item, index) in talentInfoList" style="margin-top: 5px;">
                        <a-card
                          style="border-radius: 10px; margin: auto; cursor: pointer; background: linear-gradient(89.83deg, rgba(255,255,255,1) 1.05%,rgba(147,227,201,1) 82.48%,rgba(84,211,170,1) 100.35%);"
                          size="small"
                          :class="selectedOrgUserId == item.id ? 'bordc' : ''"
                          @click="changFruitData(item.id, item.talentRealName, true)">
                          <div style="position: absolute; right: 10px; top: 0;">
                            {{ index == 0 ? '🌟🌟🌟' : index == 1 ? '🌟🌟' : index == 2 ? '🌟' : '' }}
                          </div>
                          <a-row>
                            <a-col span="6">
                              <a-avatar shape="square" :size="100"
                                        :src="item.talentPhoto != null ? item.talentPhoto : item.talentGender != null ? item.talentGender== '男' ? manPhoto : womanPhoto : unknownPhoto"
                                        style="height: 100px;" />
                            </a-col>
                            <a-col span="18">
                              <div style="padding-left: 5px;">
                                <a-row style=" line-height: 30px; ">
                                  <a-col span="8"
                                         style="color: rgba(3, 129, 129, 1); font-size: 28px; cursor: pointer; font-weight: bold; padding-left: 5px;">
                                    {{ item.talentRealName }}
                                  </a-col>
                                  <a-col span="16"
                                         style="font-weight: bold; text-align: right">
                                    <div
                                      style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 5px;"
                                      :title="item.talentCompany">
                                      {{ item.talentCompany }}
                                    </div>
                                  </a-col>
                                </a-row>
                                <a-row style="padding-top: 5px; line-height: 40px; ">
                                  <a-col span="8" style="font-weight: bold;">
                                    <div
                                      style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 5px;">
                                      {{ item.talentPartPhoneNumber }}
                                    </div>
                                  </a-col>
                                  <a-col span="16"
                                         style="font-weight: bold; text-align: right"
                                         v-if="item.talentCooperationNum > 0">
                                    合作次数：{{ item.talentCooperationNum }}次
                                  </a-col>
                                </a-row>
                                <a-row style="">
                                  <a-col span="24">
                                    <template v-for="(tag,index) in item.fieldNames">
                                      <a-tag :title="tag.tagName" v-if="index<3 && tag.tagName != ''"
                                             style="line-height: 20px; background: #64ccc4; border-style: dashed; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  max-width: 100px; float: left;">
                                        {{ tag.tagName }}
                                      </a-tag>
                                    </template>
                                  </a-col>
                                </a-row>
                              </div>
                            </a-col>
                          </a-row>
                        </a-card>
                      </div>
                      <!--                                            <div style="text-align: center; font-size: 15px; padding-top: 15px; font-weight: bold; cursor: pointer;"-->
                      <!--                                                 v-if="talentInfoList.total > 10"-->
                      <!--                                                 @click="showAllTalentInfo(1)">查看全部....</div>-->
                    </div>
                    <div v-else>
                      <a-empty>
                        <template #description>
                          <span>
                            暂无专家推荐
                          </span>
                        </template>
                      </a-empty>
                      <br />
                      <!--                                            <a-divider orientation="left">为您推荐了其他领域的相关专家</a-divider>-->
                      <!--                                            <div v-if="isHaveOtherDataTalent">-->
                      <!--                                                <div v-if="otherTalentInfoList.length > 0" style="padding-top: 15px;">-->
                      <!--                                                    <div v-for="item in otherTalentInfoList" style="margin-top: 5px;">-->
                      <!--                                                        <a-card style="border-radius: 10px; margin: auto; cursor: pointer; background: linear-gradient(89.83deg, rgba(255,255,255,1) 1.05%,rgba(147,227,201,1) 82.48%,rgba(84,211,170,1) 100.35%);" size="small"-->
                      <!--                                                                :class="selectedOrgUserId == item.authorId ? 'bordc' : ''"-->
                      <!--                                                                @click="changFruitData(item.authorId, item.authorName, false)">-->
                      <!--                                                            <a-row>-->
                      <!--                                                                <a-col span="6">-->
                      <!--                                                                    <a-avatar shape="square" :size="100" :src="photo" />-->
                      <!--                                                                </a-col>-->
                      <!--                                                                <a-col span="18">-->
                      <!--                                                                    <div style="padding-left: 5px;">-->
                      <!--                                                                        <a-row>-->
                      <!--                                                                            <a-col span="8" style="color: rgba(3, 129, 129, 1); font-size: 28px; cursor: pointer; line-height: 30px; font-weight: bold;">-->
                      <!--                                                                                {{item.authorName}}-->
                      <!--                                                                            </a-col>-->
                      <!--                                                                            <a-col span="16" style="line-height: 30px; font-size: 18px; font-weight: bold; color: #FD8024; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"-->
                      <!--                                                                                   :title="item.field">-->
                      <!--                                                                                {{item.field}}-->
                      <!--                                                                            </a-col>-->
                      <!--                                                                        </a-row>-->
                      <!--                                                                        <a-row>-->
                      <!--                                                                            <a-col span="6" style="padding-top: 10px;font-weight: bold;">-->
                      <!--                                                                                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.phoneNumber}}</div>-->
                      <!--                                                                            </a-col>-->
                      <!--                                                                            <a-col span="18" style="padding-top: 10px;font-weight: bold; text-align: right">-->
                      <!--                                                                                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{item.company}}</div>-->
                      <!--                                                                            </a-col>-->
                      <!--                                                                        </a-row>-->
                      <!--                                                                        <a-row>-->
                      <!--                                                                            <a-col span="24" style="padding-top: 10px;font-weight: bold;">合作次数：{{item.cooperationNum}}次</a-col>-->
                      <!--                                                                        </a-row>-->
                      <!--                                                                    </div>-->
                      <!--                                                                </a-col>-->
                      <!--                                                            </a-row>-->
                      <!--                                                        </a-card>-->
                      <!--                                                    </div>-->
                      <!--                                                    <div style="text-align: center; font-size: 15px; padding-top: 15px; font-weight: bold; cursor: pointer;"-->
                      <!--                                                         v-if="otherTalentInfoList.total > 10"-->
                      <!--                                                         @click="showAllTalentInfo(2)">查看全部....</div>-->
                      <!--                                                </div>-->
                      <!--                                            </div>-->
                    </div>
                  </div>
                </a-col>
                <a-col span="14">
                  <a-card size="small" style="border-radius: 10px;">
                    <a-spin tip="数据加载中..." v-if="!isHaveFruitData">
                      <div class="spin-content">
                      </div>
                    </a-spin>
                    <div v-if="isHaveFruitData">
                      <div v-if="talentFruitList.length > 0">
                        <div
                          style="font-weight: bolder; color: rgba(3, 129, 129, 1); font-size: 20px;">
                          <div style="line-height: 40px; float: left;" v-if="selectedType == 3">
                            {{ selectedAuthorName }}&nbsp;&nbsp;&nbsp;相关成果推荐
                          </div>
                          <div style="line-height: 40px; float: left;" v-else>
                            {{ selectedAuthorName }}&nbsp;&nbsp;&nbsp;的成果
                          </div>
                        </div>
                        <div>
                          <a-button type="primary" style="margin: 5px 50px; border-radius: 50px;"
                                    @click="toInfo()">
                            查看专家画像
                          </a-button>
                        </div>
                        <div style="border-top: 1px solid #c7c5c5; padding: 15px;"
                             v-for="item in talentFruitList">
                          <a-row>
                            <a-col span="20">
                              <div class="ft" @click="showFruitInfo(item)">
                                <span v-html="item.fruitName"></span>
                              </div>
                            </a-col>
                            <a-col span="4">
                              <div style="text-align: right;">
                                <span
                                  style="font-size: 15px; border-radius: 10px; color: #fff; padding: 5px 10px; background: linear-gradient(93.32deg, rgba(25,151,133,1) 2.78%,rgba(84,211,170,1) 97.62%)">
                                  <span>{{ getFruitTypeName(item.fruitType) }}</span>
                                </span>
                              </div>
                            </a-col>
                          </a-row>
                          <a-row style="margin-top: 5px;">
                            <a-col span="24">
                              <template v-if="item.fruitKeywords">
                                <template v-for="tag in item.fruitKeywords.split(',')">
                                  <a-tag :key="tag"
                                         style="line-height: 20px; border-style: dashed; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  max-width: 200px; float: left;"
                                         :color="tag.includes(searchObj.content) ? 'red' : '#87d068'">
                                    {{ tag }}
                                  </a-tag>
                                </template>
                              </template>
                            </a-col>
                          </a-row>
                          <a-row :gutter="6" style="margin-top: 5px;">
                            <a-col span="18">
                              <div style="font-size: 15px; ">
                                <div v-if="item.tagList">
                                                                <span v-for="(tagGroup, index) in item.tagList"
                                                                      :key="index">
                                                                  <span
                                                                    v-if="tagGroup.tagTypeName === 'fruit_author_names'">
                                                                      {{ tagGroup.tagName }}
                                                                    <!--                                                                    <span v-for="(author, idx) in tagGroup.tagNameList"-->
                                                                    <!--                                                                          :key="idx">-->
                                                                    <!--                                                                      {{ author.tagName }}-->
                                                                    <!--                                                                      <span-->
                                                                    <!--                                                                          v-if="idx < tagGroup.tagNameList.length - 1">, </span>-->
                                                                    <!--                                                                    </span>-->
                                                                  </span>
                                                                </span>
                                </div>
                              </div>
                              <div style="font-size: 15px;">{{ item.orgName }}</div>
                            </a-col>
                            <a-col span="6">
                              <div style="font-size: 15px; text-align: right;">{{ item.fruitPubTime }}</div>
                            </a-col>
                          </a-row>
                        </div>
                        <div class="pagCs">
                          <a-pagination :current="currentPageNo"
                                        :total="parseInt(talentFruitListTotal)"
                                        :show-total="total => `共 ${total} 条`"
                                        @change="onChangePage" />
                        </div>
                      </div>
                      <div v-else>
                        <a-empty>
                          <span slot="description"> 暂无成果数据 </span>
                        </a-empty>
                      </div>
                    </div>
                  </a-card>
                </a-col>
              </a-row>
            </a-card>
          </a-col>
        </a-row>
      </div>
      <div v-else>
        <EsTalentAdvancedSearch :sc="searchContent" :st="selectedType" @backSearch="backSearch" />
      </div>
    </div>

    <fruit-info ref="fruitInfo"></fruit-info>

    <a-modal :width="500" v-model="feedbackModal" title="搜索结果反馈" :mask-closable="false" :footer="null">
      <div class="feedback-content">
        <div class="feedback-section">
          <div class="section-title">反馈类型：</div>
          <div class="feedback-types">
            <a-radio-group v-model="feedBackForm.feedBackType">
              <a-radio-button value="推荐专家异常" class="radio-button">
                推荐专家异常
              </a-radio-button>
              <a-radio-button value="专家成果异常" class="radio-button">
                专家成果异常
              </a-radio-button>
              <a-radio-button value="专家基础信息异常" class="radio-button">
                专家基础信息异常
              </a-radio-button>
            </a-radio-group>
          </div>
        </div>
        <div class="feedback-section">
          <div class="section-title">您的问题或建议：</div>
          <a-textarea
            v-model="feedBackForm.feedBackContent"
            placeholder="请简单描述您的问题和建议"
            :rows="6"
            class="feedback-textarea"
            :maxLength="200"
          />
        </div>
        <div class="submit-section">
          <a-button type="primary" class="submit-button" @click="handleSubmitFeedBack">
            提交
          </a-button>
        </div>
      </div>
    </a-modal>

    <div id="components-back-top-demo-custom">
      <a-back-top>
        <div class="ant-back-top-inner">
          <a-icon type="up-circle" theme="filled" />
        </div>
      </a-back-top>
    </div>
  </div>
</template>

<script>

import fruitInfo from '../FruitInfo.vue'
import { commonPostAction, postAction } from '@/api/esManage'
import { getFruitTypeName } from '@/utils/tools'
import { getBeforeMonth, etCurrentDate, getMonthFirstDay, getMonthLastDay, getCurrentDate } from '../common/dateTool'
import photo from '../common/photo.png'
import womanPhoto from '@/views/talentCooperation/common/womanPhoto.png'
import manPhoto from '@/views/talentCooperation/common/manPhoto.png'
import unknownPhoto from '@/views/talentCooperation/common/unknownPhoto.png'

const Setting = require('@/setting')
import EsTalentAdvancedSearch from './EsTalentAdvancedSearch.vue'

function removeDuplicates(inputString, chartSeq) {
  const charArray = inputString.split(chartSeq)
  const uniqueChars = [...new Set(charArray)]
  return uniqueChars.join(' ')
}

export default {
  name: 'TalentFruit',
  props: {},
  components: {
    fruitInfo,
    EsTalentAdvancedSearch
  },
  data() {
    return {
      basePath: Setting.talentChatPath,
      photo: photo,
      womanPhoto: womanPhoto,
      manPhoto: manPhoto,
      unknownPhoto: unknownPhoto,
      selectedType: 1,
      searchContent: '',
      loading: false,
      showPhotoPage: false,
      isHaveData: true,
      isHaveDataTalent: true,
      isHaveFruitData: true,
      searchObj: {
        current: 1,
        pageNo: 1,
        pageSize: 10,
        sortField: 'talentCooperationNum'
      },
      searchTalentFruitObj: {
        current: 1,
        pageNo: 1,
        pageSize: 10,
        sortField: 'fruitPubTime'
      },
      selectedBtnType: '',
      rangeValue: [],
      deptTypes: [
        { 'name': '公司 / 企业', 'description': '商业公司和其他营利性实体。' },
        { 'name': '政府机构', 'description': '国家和地方政府的行政、立法、司法机构。' },
        // { "name": "非政府组织 (NGO)", "description": "独立于政府控制的公益性组织。"},
        { 'name': '教育机构', 'description': '提供教育服务的学校、大学和研究机构。' },
        // { "name": "宗教组织", "description": "宗教团体或组织。"},
        // { "name": "军事组织", "description": "军队和国防相关组织。"},
        // { "name": "国际组织", "description": "跨越国界的多国或全球性机构。"},
        // { "name": "非盈利组织 (NPO)", "description": "不以营利为目的的机构，通常从事公益或慈善活动。"},
        { 'name': '金融机构', 'description': '从事银行、保险、证券等金融服务的组织。' },
        // { "name": "体育组织", "description": "从事体育竞技、赛事组织等相关的机构。"},
        { 'name': '媒体机构', 'description': '提供新闻、娱乐、广播、出版等信息服务的组织。' },
        { 'name': '科技研究机构', 'description': '从事科学研究与技术开发的实验室、研究所等。' }
        // { "name": "文化和艺术机构", "description": "从事文化、艺术相关的组织，如博物馆、剧院等。"},
        // { "name": "医疗机构", "description": "提供医疗和卫生服务的组织，包括医院、诊所等。"}
      ],
      currentPageNo: 1,
      talentInfoList: [],
      talentFruitList: [],
      talentFruitListTotal: 0,
      selectedOrgUserId: '',
      selectedAuthorName: '',
      isContainField: true,
      feedBackLoading: false,
      feedbackModal: false,
      feedBackForm: {
        feedBackType: '',
        feedBackContent: ''
      },
      isAdvanceSearch: false,
      sortIndex: 1
    }
  },
  computed: {},
  created() {
  },
  methods: {
    getFruitTypeName,
    handleChange(value) {
      console.log(`selected ${value}`)
      this.selectedType = value
    },
    backMain() {
      this.searchObj = {
        current: 1,
        pageNo: 1,
        pageSize: 10,
        sortField: 'talentCooperationNum'
      }
      this.$emit('changeShow', true, false, false, this.searchObj)
    },
    showFruitInfo(item) {
      this.$nextTick(() => {
        this.$refs.fruitInfo.showModalInfo(item)
      })
    },
    toInfo() {
      const routeUrl = this.$router.resolve({
        name: 'esTalentInfo',
        query: { 't': this.selectedOrgUserId, 'c': this.selectedAuthorName }
      })
      window.open(routeUrl.href, '_blank')
    },
    addSearchContentLog(value) {
      let url = '/operationLog/add'
      if (Setting.isMock) {
        window.localStorage.setItem('sysUserId', '1229')
        window.localStorage.setItem('realname', '李正正')
      }
      let userId = window.localStorage.getItem('sysUserId')
      let realName = window.localStorage.getItem('realname')
      commonPostAction(url, {
        content: value,
        userId: userId,
        userName: realName,
        searchType: this.selectedType
      }).then(res => {
        if (res.data.success) {
        }
      }).catch(err => {
        console.log(err)
      })
    },
    toSearch(value) {
      this.showPhotoPage = false
      this.isHaveData = false
      this.searchObj = JSON.parse(JSON.stringify(value))
      console.log(this.searchObj)
      this.searchContent = this.searchObj.content
      this.selectedType = this.searchObj.searchType
      this.getData()
      this.addSearchContentLog(this.searchContent)
    },
    onSearch(value) {
      if (!value) {
        this.$message.error('请输入内容！')
        return
      }
      this.searchContent = value
      // this.$emit('changeObj', this.selectedType, value);
      this.currentPageNo = 1
      this.isHaveData = false
      this.searchObj.current = 1
      this.searchObj.pageNo = 1
      this.searchObj.pageSize = 10
      this.searchObj.searchType = this.selectedType
      this.searchObj.content = value
      this.searchObj.deptTypes = []
      this.talentFruitList = []
      this.talentFruitListTotal = 0
      this.getData()
      this.addSearchContentLog(value)
    },
    getData() {
      this.searchObj.orgUserId = null
      this.selectedAuthorName = ''
      this.getTalentData()
    },
    getTalentData() {
      let url = '/talents/searchPageTalentData'

      this.loading = true
      this.isHaveDataTalent = false

      this.selectedOrgUserId = ''
      this.selectedAuthorName = ''
      postAction(url, this.searchObj).then(res => {
        if (res.data.success) {
          this.talentInfoList = res.data.result.records
          this.loading = false
          this.isHaveDataTalent = true
          let resArr = this.talentInfoList
          if (resArr.length > 0) {
            resArr.forEach((talentInfo, index) => {
              if (resArr[index].tagList) {
                const foundTag = resArr[index].tagList.find(
                  tag => tag.tagTypeName === 'gw_research_field_name'
                )
                if (foundTag) {
                  talentInfo.fieldNames = foundTag.tagNameList
                }
              }
            })
            this.selectedOrgUserId = resArr[0].id
            this.selectedAuthorName = resArr[0].talentRealName
            this.getTalentFruitList()
          } else {
            this.talentFruitList = []
            this.talentFruitListTotal = 0
          }
        }
      }).catch(err => {
        console.log(err)
        this.loading = false
      })
    },
    changFruitData(authorId, authorName, isContainField) {
      this.selectedOrgUserId = authorId
      this.selectedAuthorName = authorName
      this.isContainField = isContainField
      this.currentPageNo = 1
      this.searchTalentFruitObj = {
        current: 1,
        pageNo: 1,
        pageSize: 10,
        sortField: 'fruitPubTime'
      }
      window.scrollTo({
        top: 0,
        behavior: 'smooth' // 使用平滑滚动
      })
      this.getTalentFruitList()
    },
    getTalentFruitList() {
      let fruitUrl = '/talents/getPageTalentFruitList'
      this.searchTalentFruitObj.authorId = this.selectedOrgUserId
      // this.searchTalentFruitObj.authorName = this.selectedAuthorName;
      this.searchTalentFruitObj.content = this.searchContent
      this.searchTalentFruitObj.searchType = this.selectedType
      this.searchTalentFruitObj.pubStartDate = this.searchObj.pubStartDate
      this.searchTalentFruitObj.pubEndDate = this.searchObj.pubEndDate
      this.isHaveFruitData = false
      postAction(fruitUrl, this.searchTalentFruitObj).then(res => {
        if (res.data.success) {
          this.talentFruitList = res.data.result.records
          this.talentFruitListTotal = res.data.result.total
          this.isHaveFruitData = true
        }
      }).catch(err => {
        console.log(err)
      })
    },
    dataChange(date, dateString) {
      this.rangeValue = date
      this.searchObj.pubStartDate = dateString[0]
      this.searchObj.pubEndDate = dateString[1]
      this.searchObj.current = 1
      this.searchObj.pageNo = 1
      this.currentPageNo = 1
      this.getData()
    },
    setDateType(value) {
      this.rangeValue = []
      this.searchObj.pubStartDate = ''
      this.searchObj.pubEndDate = getCurrentDate()
      if (value === this.selectedBtnType) {
        this.selectedBtnType = ''
        this.searchObj.pubStartDate = ''
        this.searchObj.pubEndDate = ''
      } else {
        this.selectedBtnType = value
        this.searchObj.pubStartDate = getMonthFirstDay(getBeforeMonth(value * 12))
      }
      this.getData()
    },
    onChangeDeptType(checkedValues) {
      this.searchObj.deptTypes = checkedValues
      this.searchObj.orgUserId = null
      this.getTalentData(true)
    },
    onChangePage(event) {
      // 重新赋值
      this.currentPageNo = event
      this.searchTalentFruitObj.current = event
      this.searchTalentFruitObj.pageNo = event
      this.getTalentFruitList(this.searchTalentFruitObj)
      window.scrollTo({
        top: 0,
        behavior: 'smooth' // 使用平滑滚动
      })
    },
    advancedSearch() {
      // const routeUrl = this.$router.resolve({
      //     name: 'esTalentAdvancedSearch',
      //     query: {"sc": this.searchContent, 'st': this.selectedType}
      // });
      // window.open(routeUrl.href, '_blank');
      this.isAdvanceSearch = true
    },
    backSearch() {
      this.isAdvanceSearch = false
    },
    toFeedBack() {
      this.feedBackForm = {}
      this.feedbackModal = true
    },
    handleSubmitFeedBack() {
      if (!this.feedBackForm.feedBackType) {
        this.$message.error('请选择反馈类型！')
        return
      }
      if (!this.feedBackForm.feedBackContent) {
        this.$message.error('请填写反馈内容！')
        return
      }
      let url = '/feedBack/add'
      this.feedBackForm.searchContent = this.searchContent
      this.feedBackForm.searchType = this.selectedType
      this.feedBackForm.type = 1
      if (Setting.isMock) {
        window.localStorage.setItem('sysUserId', '1229')
        window.localStorage.setItem('realname', '李正正')
      }
      this.feedBackForm.userId = window.localStorage.getItem('sysUserId')
      this.feedBackForm.userName = window.localStorage.getItem('realname')
      this.feedBackLoading = true
      commonPostAction(url, this.feedBackForm).then(res => {
        if (res.data.success) {
          this.feedBackLoading = false
          this.feedbackModal = false
          this.$success({
            title: '反馈成功'
          })
        }
      }).catch(err => {
        console.log(err)
      })
    },
    sortResult(){
      if(this.sortIndex === 1){
        this.talentInfoList.sort((a, b) => b.talentCooperationNum - a.talentCooperationNum);
      }else if(this.sortIndex == 2){
        this.talentInfoList.sort((a, b) => b.talentContributionIndex - a.talentContributionIndex);
      }
      this.selectedOrgUserId = this.talentInfoList[0].id
      this.selectedAuthorName = this.talentInfoList[0].talentRealName
      this.getTalentFruitList()
    }
  }
}
</script>
<style scoped>

.header_search {
  /*width: 800px;*/
  margin: auto;
}

/deep/ .header_search .ant-input-group .ant-input {
  height: 50px !important;
  line-height: 50px !important;
}

/deep/ .header_search .ant-input-group .ant-input-affix-wrapper {
  font-size: 20px;
}

/deep/ .header_search .ant-card-small > .ant-card-head {
  border-bottom: 1px solid #038181 !important;
}

/deep/ .header_search .ant-input-group .ant-input-group-addon {
  border-radius: 50px 0 0 50px !important;
}

/deep/ .header_search .ant-input-group .ant-input {
  border-radius: 0 50px 50px 0 !important;
}

/deep/ .header_search .ant-input-clear-icon {
  padding-right: 100px !important;
}

/deep/ .header_search .ant-input-affix-wrapper .ant-input {
  border-radius: 50px;
  height: 50px !important;
  padding-left: 20px;
}

/deep/ .header_search .ant-input-search-icon {
  font-size: 25px;
}

/deep/ .chat .ant-card-small > .ant-card-body {
  padding: 1px;
}

.ant-tag {
  margin-top: 2px !important;
}

.dateBtn {
  height: 30px;
  font-size: 16px;
}

.cardTit {
  font-size: 18px;
  font-weight: bold;
}

.ft {
  font-weight: bold;
  font-size: 20px;
  cursor: pointer;
}

.pagCs {
  padding: 20px 0;
  text-align: center;
}

.bordc {
  border: 5px solid #9dfb76;
}

.spin-content {
  border: 1px solid #91d5ff;
  background-color: #e6f7ff;
  padding: 30px;
}

#components-back-top-demo-custom .ant-back-top {
  bottom: 100px;
  right: 20px;
}

#components-back-top-demo-custom .ant-back-top-inner {
  height: 40px;
  width: 40px;
  line-height: 40px;
  border-radius: 4px;
  background-color: rgba(0, 128, 128, 1);
  color: #fff;
  text-align: center;
  font-size: 20px;
}

.feedback-content {
  padding: 0 24px;
}

.feedback-section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  color: #1B9C85;
  margin-bottom: 16px;
  font-weight: 500;
}

.feedback-types {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.feedback-textarea {
  border-color: #1B9C85;
  border-radius: 4px;
}

.submit-section {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
}

.feedback-textarea {
  border-color: #1B9C85;
  border-radius: 4px;
}

.submit-button {
  background-color: #1B9C85;
  border-color: #1B9C85;
  width: 120px;
  height: 40px;
  font-size: 16px;
  border-radius: 4px;
}

.submit-button:hover, .submit-button:focus {
  background-color: #148f7a;
  border-color: #148f7a;
}
</style>